﻿package mortal.game.view.firstReCharge
{
    import Message.DB.Tables.*;
    import Message.Game.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.view.common.*;
    import mortal.mvc.core.*;

    public class FirstReChargeIcon extends ActionToolTipIcon
    {
        private var _time:int;
        private static var _instance:FirstReChargeIcon;

        public function FirstReChargeIcon()
        {
            super("FirstReChargeIcon");
            this.name = "FirstReChargeIcon";
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.name = "FirstReChargeIcon";
            var _loc_1:* = ClockManager.instance.serverOpenDateNum;
            if (_loc_1 <= FirstRechargeModule.rewardArr.length)
            {
                this.toolTipData = this.getToolTip;
            }
            return;
        }// end function

        private function getToolTip()
        {
            var _loc_1:* = ClockManager.instance.serverOpenDateNum - 1;
            var _loc_2:* = ItemConfig.instance.getConfig(FirstRechargeModule.rewardArr[_loc_1]) as ItemGiftBagInfo;
            if (_loc_2 == null)
            {
                MsgManager.showRollTipsMsg(Language.getStringByParam(21476, ClockManager.instance.serverOpenDateNum));
                return "";
            }
            var _loc_3:* = PlayerModelConfig.instance.getModelShowInfo(_loc_2.effect, Cache.instance.role.entityInfo.sex, Cache.instance.role.entityInfo.career);
            var _loc_4:* = new FirstRechargeTipsData();
            _loc_4.tModelShow = _loc_3;
            _loc_4.itemData = new ItemData(_loc_2.code);
            return _loc_4;
        }// end function

        override public function get width() : Number
        {
            return 56;
        }// end function

        override public function get height() : Number
        {
            return 54;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this.name = "";
            super.disposeImpl(param1);
            return;
        }// end function

        override protected function clickHandler(event:MouseEvent) : void
        {
            var _loc_2:* = Cache.instance.firstRecharge.firstRechargeRewardInfo;
            if (_loc_2.rechargeNum <= 0)
            {
                FirstReChargeIcon.instance.stopEffect();
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.FirstRechargeWinOpen, null));
            return;
        }// end function

        public static function get instance() : FirstReChargeIcon
        {
            if (!_instance)
            {
                _instance = new FirstReChargeIcon;
            }
            return _instance;
        }// end function

        public static function get isViewShow() : Boolean
        {
            return _instance && !_instance.isHide;
        }// end function

    }
}
